|
|
|
|
|
|
|
The ServiceStatus class contains the following code. The most recent status is stored in a private SERVICE_STATUS structure called Status. The service name and display name are stored as well. |
|
|
|
|
|
|
|
|
There are two ways to initialize a ServiceStatus object. One is by parsing a buffer created by the EnumServicesStatus function. The other is by setting the private information directly using the InternalInitialize function. This function is called by the ServiceObject class when a client requests updated status information. |
|
|
|
|
|
|
|
|
' Holds the latest value of each
Private Status As SERVICE_STATUS
Private SvcName As String
Private intDisplayName As String
' Used by the internal objects to initialize a new ServiceStatus object
' that is not created via an enumeration.
Friend Sub Internallnitialize(pName As String, pDisplay As String, _
stat As SERVICE_STATUS)
intDisplayName = pDisplay
SvcName = pName
LSet Status = stat
End Sub |
|
|
|
|
|
|
|
|
The ParseServiceInfo function first copies the part of the buffer that contains the information for this service into a private ENUM_SERVICE_STATUS structure. The first two fields of this structure contain pointers to the service name and display name. These pointers need to be converted into Visual Basic strings using the GetVBStringFromAddress function, which can be found in the modSCMgr module and should be quite familiar to you by now. |
|
|
|
|
|
|
|
|
' Extracts the private information from the buffer. Data is assumed
' to start at the specified offset
' Always returns 0
Friend Function ParseServiceInfo(Buffer() As Byte, ByVal Offset As Long) _
As Long
Dim svcstat As ENUM_SERVICE_STATUS
' Copy the service structure
Call RtlMoveMemory(VarPtr(svcstat), VarPtr(Buffer(Offset)), Len(svcstat))
' Extract the names
SvcName = GetVBStringFromAddress(svcstat.lpServiceName)
intDisplayName = GetVBStringFromAddress(svcstat.lpDisplayName)
' Store the SERVICE_STATUS portion only
LSet Status = svcstat.Status |
|
|
|
|
|